home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / t_unix / j109lxa4.tar / lapb.h < prev    next >
C/C++ Source or Header  |  1994-06-04  |  5KB  |  154 lines

  1. #ifndef    _LAPB_H
  2. #define    _LAPB_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifndef    _MBUF_H
  9. #include "mbuf.h"
  10. #endif
  11.  
  12. #ifndef    _IFACE_H
  13. #include "iface.h"
  14. #endif
  15.  
  16. #ifndef    _TIMER_H
  17. #include "timer.h"
  18. #endif
  19.  
  20. #ifndef    _AX25_H
  21. #include "ax25.h"
  22. #endif
  23.  
  24. /* Upper sub-layer (LAPB) definitions */
  25.  
  26. /* Control field templates */
  27. #define    I    0x00    /* Information frames */
  28. #define    S    0x01    /* Supervisory frames */
  29. #define    RR    0x01    /* Receiver ready */
  30. #define    RNR    0x05    /* Receiver not ready */
  31. #define    REJ    0x09    /* Reject */
  32. #define    U    0x03    /* Unnumbered frames */
  33. #define    SABM    0x2f    /* Set Asynchronous Balanced Mode */
  34. #define    DISC    0x43    /* Disconnect */
  35. #define    DM    0x0f    /* Disconnected mode */
  36. #define    UA    0x63    /* Unnumbered acknowledge */
  37. #define    FRMR    0x87    /* Frame reject */
  38. #define    UI    0x03    /* Unnumbered information */
  39. #define    PF    0x10    /* Poll/final bit */
  40.  
  41. #define    MMASK    7    /* Mask for modulo-8 sequence numbers */
  42.  
  43. /* FRMR reason bits */
  44. #define    W    1    /* Invalid control field */
  45. #define    X    2    /* Unallowed I-field */
  46. #define    Y    4    /* Too-long I-field */
  47. #define    Z    8    /* Invalid sequence number */
  48.  
  49. /* Per-connection link control block
  50.  * These are created and destroyed dynamically,
  51.  * and are indexed through a hash table.
  52.  * One exists for each logical AX.25 Level 2 connection
  53.  */
  54. struct ax25_cb {
  55.     struct ax25_cb *next;        /* Linked list pointers */
  56.  
  57.     struct iface *iface;        /* Interface */
  58.  
  59.     struct mbuf *txq;        /* Transmit queue */
  60.     struct mbuf *rxasm;        /* Receive reassembly buffer */
  61.     struct mbuf *rxq;        /* Receive queue */
  62.  
  63.     char local[AXALEN];        /* Addresses */
  64.     char remote[AXALEN];
  65.  
  66.     struct {
  67.         char rejsent;        /* REJ frame has been sent */
  68.         char remotebusy;    /* Remote sent RNR */
  69.         char rtt_run;        /* Round trip "timer" is running */
  70.         char retrans;        /* A retransmission has occurred */
  71.         char clone;         /* Server-type cb, will be cloned */
  72.         char rxd_I_frame;   /* I-frame received */
  73.     } flags;
  74.  
  75.     char reason;            /* Reason for connection closing */
  76. #define    LB_NORMAL    0        /* Normal close */
  77. #define    LB_DM        1        /* Received DM from other end */
  78. #define    LB_TIMEOUT    2        /* Excessive retries */
  79. #define LB_UNUSED    3        /* Link is redundant - unused */
  80.  
  81.     char response;            /* Response owed to other end */
  82.     char vs;            /* Our send state variable */
  83.     char vr;            /* Our receive state variable */
  84.     char unack;            /* Number of unacked frames */
  85.     int maxframe;            /* Transmit flow control level, frames */
  86.     int16 paclen;            /* Maximum outbound packet size, bytes */
  87.     int16 window;            /* Local flow control limit, bytes */
  88.     char proto;            /* Protocol version */
  89. #define    V1    1            /* AX.25 Version 1 */
  90. #define    V2    2            /* AX.25 Version 2 */
  91.     int16 pthresh;            /* Poll threshold, bytes */
  92.     unsigned retries;        /* Retry counter */
  93.     unsigned n2;            /* Retry limit */
  94.     int state;            /* Link state */
  95. #define    LAPB_DISCONNECTED    1
  96. #define LAPB_LISTEN        2
  97. #define    LAPB_SETUP        3
  98. #define    LAPB_DISCPENDING    4
  99. #define    LAPB_CONNECTED        5
  100. #define    LAPB_RECOVERY        6
  101.     struct timer t1;        /* Retry timer */
  102.     struct timer t3;        /* Keep-alive poll timer */
  103.     struct timer t4;        /* Link redundancy timer */
  104.     int32 rtt_time;            /* Stored clock values for RTT, ticks */
  105.     int rtt_seq;            /* Sequence number being timed */
  106.     int32 srt;            /* Smoothed round-trip time, ms */
  107.     int32 mdev;            /* Mean rtt deviation, ms */
  108.  
  109.     void (*r_upcall) __ARGS((struct ax25_cb *,int));    /* Receiver upcall */
  110.     void (*t_upcall) __ARGS((struct ax25_cb *,int));    /* Transmit upcall */
  111.     void (*s_upcall) __ARGS((struct ax25_cb *,int,int));    /* State change upcall */
  112.  
  113.     int user;            /* User pointer */
  114.     int segremain;            /* Segmenter state */
  115.     int jumpstarted;    /* Was this one jumpstarted ? */
  116. #define KNOWN_LINK  1       /* incoming conn. is already known in cb list */
  117. #define NETROM_LINK 2       /* new connection to netrom interface call */
  118. #define ALIAS_LINK  4       /* new connection to alias call */
  119. #define CONF_LINK   8       /* new connection to conference call */
  120. #define IFACE_LINK  16      /* new connection to the interface call */
  121. #define NR4_LINK    32
  122. #define TELNET_LINK 64
  123. #define JUMPSTARTED 128     /* jumpstart was used */
  124. #define TIP_LINK    256
  125. #define TTY_LINK    512        /* new connection to the ttylink call */
  126. };
  127. #define    NULLAX25    ((struct ax25_cb *)0)
  128. extern struct ax25_cb Ax25default,*Ax25_cb;
  129. extern char *Ax25states[],*Axreasons[];
  130. extern int32 Axirtt,T3init,T4init,Blimit;
  131. extern int16 N2,Maxframe,Paclen,Pthresh,Axwindow,Axversion;
  132.  
  133. /* In lapb.c: */
  134. void est_link __ARGS((struct ax25_cb *axp));
  135. void lapbstate __ARGS((struct ax25_cb *axp,int s));
  136. int lapb_input __ARGS((struct ax25_cb *axp,int cmdrsp,struct mbuf *bp));
  137. int lapb_output __ARGS((struct ax25_cb *axp));
  138. struct mbuf *segmenter __ARGS((struct mbuf *bp,int16 ssize));
  139. int sendctl __ARGS((struct ax25_cb *axp,int cmdrsp,int cmd));
  140.  
  141. /* In lapbtimer.c: */
  142. void pollthem __ARGS((void *p));
  143. void recover __ARGS((void *p));
  144. void redundant __ARGS((void *p));
  145.  
  146. /* In ax25subr.c: */
  147. int16 ftype __ARGS((int control));
  148. void lapb_garbage __ARGS((int drastic));
  149.  
  150. /* In nr3.c: */
  151. void nr_derate __ARGS(( struct ax25_cb *axp));
  152.  
  153. #endif    /* _LAPB_H */
  154.